class Solution(object):
    def removeDuplicates(self, nums):
        n = len(nums)
        if n <= 2:
            return n
        slow,fast = 2,2
        while fast < n:
            if nums[slow - 2] != nums[fast]:
                nums[slow] = nums[fast]
                slow += 1
            fast += 1

        return slow

if __name__ == '__main__':
    s = Solution()
    nums = [1,1,1,2,3]
    s.removeDuplicates(nums)
    print(nums)